import 'package:pacsun/view/task/theme/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';

class CommonTransparentAppBar extends StatelessWidget
    implements PreferredSizeWidget {
  final VoidCallback? onBack;
  final Color iconColor;
  final double elevation;
  final String title;
  final Color backgroundColor;
  final double height;

  const CommonTransparentAppBar({
    super.key,
    this.onBack,
    this.iconColor = Colors.white,
    this.elevation = 0,
    this.title = '',
    this.backgroundColor = Colors.transparent,
    this.height = kToolbarHeight,
  });
  @override
  Widget build(BuildContext context) {
    return AppBar(
      backgroundColor: backgroundColor,
      elevation: elevation,
      title: Text(
        title,
        style: customTextStyle(fontSize: 16, fontWeight: 600),
      ),
      leading: IconButton(
        icon: SvgPicture.asset('assets/icons/icon_appBar_arrow.svg'),
        onPressed: onBack ?? () => Navigator.pop(context),
      ),
    );
  }

  @override
  Size get preferredSize => Size.fromHeight(height);
}

class AppBarBg extends StatelessWidget {
  final double width;
  final double height;
  final BoxFit fit;
  final String bgSrc;
  const AppBarBg(
      {super.key,
      this.width = 375,
      this.height = 280,
      this.fit = BoxFit.fitWidth,
      this.bgSrc = 'assets/imgs/appCommonNavBarBg.png'});

  @override
  Widget build(BuildContext context) {
    return Positioned(
      child: Image.asset(
        bgSrc, // 替换为你的图片路径
        fit: fit,
        width: width.w,
        height: height.h,
      ),
    );
  }
}
